package com.example.usingjsontocallwcf;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

	Button btnCallButton;
	Context context=this;
	Button btnCallWcf;
	TextView listView;
	HttpClient httpClient;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		btnCallButton=(Button)findViewById(R.id.btnCall);
		btnCallButton.setOnClickListener(onClickListener);
		btnCallWcf=(Button)findViewById(R.id.btncallwcf);
		listView=(TextView) findViewById(R.id.textView1);
		 httpClient=new DefaultHttpClient();
		btnCallWcf.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				wcfAsyntask wcfAsyntasks=new wcfAsyntask(context,listView,httpClient);
				wcfAsyntasks.execute();
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	 
	OnClickListener onClickListener=new OnClickListener() {
		
		@SuppressLint("NewApi")
		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			serviceAsyn asyn=new serviceAsyn(context);
			asyn.execute();
           
		}
	};
	void Show(String text)
	{
		Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
	}

}
